package cn.bytepulse.web.video.controller;

import cn.bytepulse.annotation.Log;
import cn.bytepulse.web.video.service.PlayerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiejiebiezheyang
 * @since 2025-03-17 13:00
 */
@Tag(name = "视频播放")
@RequestMapping("/player")
@RestController
@RequiredArgsConstructor
public class PlayerController {

    private final PlayerService playerService;

    @GetMapping("/hls/{partId}/{filename}")
    @Operation(summary = "HLS文件获取")
    @Log(value = "视频播放")
    public ResponseEntity<InputStreamResource> hls(@PathVariable String partId, @PathVariable String filename) throws Exception {
        return playerService.hls(partId, filename);
    }
}
